package Similarity

import (
	"fmt"
	"math"
)

func TestAllWeight() {
	fff := []float64{1.1, 2.2}
	weight := AllWeight(func(before float64) float64 {
		return before
	}, fff...)
	fmt.Println(weight)
}

func Similarity(insert, left, right []float64) float64 {
	i := AllWeight(func(before float64) float64 {
		return before
	}, insert...)
	l := AllWeight(func(before float64) float64 {
		return before * before
	}, left...)
	r := AllWeight(func(before float64) float64 {
		return before * before
	}, right...)
	return i / math.Sqrt(l) * math.Sqrt(r)
}

// AllWeight 累加权重
func AllWeight(handle floatHandle, los ...float64) float64 {
	var wl2 float64 = 0
	for _, lo := range los {
		wl2 += handle(lo)
	}
	return wl2
}

// Weight 单个权重
func Weight(w int, s int) float64 {
	return -(math.Log(float64(w)) - math.Log(float64(s)))
}

type floatHandle = func(before float64) float64

func GetGameInTag[T comparable](s T) int {
	return 12
}
